//
//  QJNavigationController.m
//  QuanJieShopProject
//
//  Created by apple on 2018/1/30.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJNavigationController.h"
#import "QJKaiDianVC.h"
#import "QJKaiDianVCTwo.h"

@interface QJNavigationController ()

@end

@implementation QJNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

+ (void)initialize{
    if (self == [super class]) {
        //设置状态栏颜色
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
        //获取全局导航条[UINavigationBar appearance]
        //颜色设置
        [UINavigationBar appearance].barTintColor = YFColor_Red;

//        HexRGB(0xf54949);
        //字体设置
        [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:17], NSForegroundColorAttributeName : [UIColor whiteColor]}];
        //导航栏下部的线(防止黑线的出现)
        [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
        
    }
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    // 根控制器判断
    if (self.navigationController.viewControllers.count > 0) {
        
        // 非根控制器 push时隐藏tabBar
        viewController.hidesBottomBarWhenPushed = YES;
        // 非根控制器 统一设置返回按钮
        UIImage *backImage = [UIImage imageNamed:@"backArrow.png"];
        UIImage *image = [backImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(backItemAction)];
        viewController.navigationItem.leftBarButtonItem = backItem;
    
    }
    
    [super pushViewController:viewController animated:animated];
}
#pragma mark -- 返回按钮点击方法
- (void)backItemAction{

    //取值
    NSString *actionName = [YFSaveTool userDefaults:@"KD"];
    if ([actionName isEqualToString:@"rootVC"]) {
        [self popToRootViewControllerAnimated:YES];
        [YFSaveTool userDefaults:@"VC" key:@"KD"];
    }else{
        [self popViewControllerAnimated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
